package com.allen.workflow.delegate;

import lombok.extern.slf4j.Slf4j;
import org.camunda.bpm.engine.delegate.DelegateExecution;
import org.camunda.bpm.engine.delegate.DelegateVariableMapping;
import org.camunda.bpm.engine.delegate.VariableScope;
import org.camunda.bpm.engine.variable.VariableMap;

/**
 * @program: spring-boot-demo
 * @className VariableDelegation
 * @description:
 * @author: zp
 * @create: 2024-08-16 14:22
 * @Version 1.0
 **/
@Slf4j
public class VariableDelegation implements DelegateVariableMapping {

    //在调用活动执行之前被调用，以映射输入变量
    @Override
    public void mapInputVariables(DelegateExecution delegateExecution, VariableMap variableMap) {
        log.info("mapInputVariables:{}", delegateExecution.getCurrentActivityName());
        variableMap.putValue("allen", "zhang");
    }

    //在调用活动被执行后被调用，以映射输出变量
    @Override
    public void mapOutputVariables(DelegateExecution delegateExecution, VariableScope variableScope) {
        log.info("mapOutputVariables:{}", delegateExecution.getCurrentActivityName());
    }
}
